package signAction;

import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import signBean.Manager;
import com.opensymphony.xwork2.ActionContext;

public class WorkYisousuoAction {
	
	
	public String name;
	public String sex;
	public String phone;
	public String time;
	 List list;
	 String na;
	 int ipage=100;
     int allpage;
     int pages=0;
     List li1;
     int ss=3;
   public  int sign=1;
   int s=3;
	int yi=3;
	
	public int getYi() {
		return yi;
	}
	public void setYi(int yi) {
		this.yi = yi;
	}
	public int getS() {
	return s;
}
public void setS(int s) {
	this.s = s;
}
	public int getSign() {
	return sign;
}
public void setSign(int sign) {
	this.sign = sign;
}
	public int getAllpage() {
		return allpage;
	}
	public void setAllpage(int allpage) {
		this.allpage = allpage;
	}
	public int getPages() {
		return pages;
	}
	public void setPages(int pages) {
		this.pages = pages;
	}
	public String getNa() {
		return na;
	}
	public void setNa(String na) {
		this.na = na;
	}
	public List getList() {
		return list;
	}
	public void setList(List list) {
		this.list = list;
	}
	public List getLi1() {
		return li1;
	}
	public void setLi1(List li1) {
		this.li1 = li1;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getTime() {
		return time;
	}
	public void setTime(String time) {
		this.time = time;
	}
	public String execute() throws SQLException, UnsupportedEncodingException{
		  Manager naa=new Manager();
		  HttpServletRequest  request = ServletActionContext.getRequest();
			int id=(Integer)request.getSession().getAttribute("id");
		   List list=naa.yisouSuo(name,phone,sex,time,id);	
			List li1=new ArrayList();
		
		
	
		try{
			

	     int allpp=list.size();
	     allpage=(int)(allpp+ipage-1)/ipage;
	    
	     if(pages==0){
			  
			   pages=1;
			  
			   
			   }else{
			  
			  pages=getPages();
			  
			
			  } 
	    int spage=(pages-1)*ipage;
	    int num=spage+ipage;
	    if(num>allpp)
	    num=allpp;
	    for(int j=spage;j<num;j++){   
	    li1.add(list.get(j));
	   }
	
		}catch(Exception f){}
		
		setLi1(li1);
		setPages(pages);
		setAllpage(allpage);
		setS(s);
		 setSign(sign);
		setYi(yi);
		setSs(ss);
		return "list";
		
		}
	public int getSs() {
		return ss;
	}
	public void setSs(int ss) {
		this.ss = ss;
	}


	

}
